package com.zmj.retrofit2;

import com.zmj.common.http.TestApi;
import com.zmj.dto.rsp.MailChimpCampaignRsp;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.Arrays;
import java.util.HashMap;

/**
 * @author zmj
 * @date 2021-09-03 10:36
 */
@Slf4j
@SpringBootTest
public class Retrofit2 {

    @Autowired
    private TestApi httpApi;

    @BeforeAll
    static void contextLoads() {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
        String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();
        log.info(" ========== bean ==========");
        Arrays.stream(beanDefinitionNames).forEach(System.out::println);
        log.info(" ========== bean ==========");
    }

    @Test
    void testGet() {
        HashMap<String, Object> queryMap = new HashMap<>();
        queryMap.put("count", 100);
        queryMap.put("offset", 0);
        MailChimpCampaignRsp mailChimpCampaignRsp = httpApi.reports("Basic d10235f6e9b034be3d2cbe1ef31f8696-us10", queryMap);
        log.info("mailChimpCampaignRsp {}", mailChimpCampaignRsp);
    }

}
